package com.zr.daoimpl;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.zr.dao.ShowAllUsersDao;
import com.zr.model.Cuser;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 * 
 * @author HC
 *
 * @param <T>
 */
@Repository("showAllUsersDao")
public class ShowAllUsersDaoImpl<T> extends BaseDaoImpl<T> implements ShowAllUsersDao<T>{

	@Override
	public int getUsersCount() {
		int n = 0;
	     String hql = "from Cuser";
	     Query que = this.getCurrentSession().createQuery(hql);
	    List<Cuser> us = que.list();
	     n = us.size();
		return n;
	}

	@Override
	public List<Cuser> getAllUsers(int page,int rows) {
		List<Cuser> users = new ArrayList<Cuser>();
		
		String hql="from Cuser";
	    Query que=this.getCurrentSession().createQuery(hql);
	    que.setFirstResult((page-1)*rows);
		que.setMaxResults(rows);
	    users = que.list();
		return users;
	}

}
